<?php

namespace App\Repositories;

use App\Exceptions\BasicException;
use Illuminate\Support\Facades\Hash;
use function Matrix\add;    //引入hash

class WinJackpotNextRepository {

    /**
     * 获取下期奖池列表
     * @param $type
     * @return bool
     */
    public function nextGiftList($type) {
        $nextGiftList = app('model_win_jackpot_next')->where('type',$type)->orderBy('id', 'desc')->select('id','number','gift_id','ratio')->with('gift')->get()->toArray();
        return $nextGiftList;
    }

    /*
     * 新增钓鱼下期奖池
     * @param $param
     * @return bool
     * @throws BasicException
     *
     * */
    public function addNextPrize($param) {
        $addNextPrize = app('model_win_jackpot_next')->create($param);
        if ($addNextPrize) return $addNextPrize;
        throw new BasicException(93050);
    }

    /*
     * 编辑钓鱼下期奖池
     * @param $param
     * @return bool
     * @throws BasicException
     * */
    public function saveNextPrize($param) {
        $saveNextPrize = app('model_win_jackpot_next')->where('id', $param['id'])->update($param);
        if ($saveNextPrize!==false) return true;
        throw new BasicException(93051);
    }

    /*
     * 删除钓鱼下期奖池
     * @param $param
     * @return bool
     * @throws BasicException
     * */
    public function delNextPrize($param) {
        $delNextPrize = app('model_win_jackpot_next')->whereIn('id', $param)->delete();
        if ($delNextPrize) return $delNextPrize;
        throw new BasicException(93053);
    }
    /*
     * 一键修改礼物
     * @param $param
     *
     * */
    public function editNextAllGifts($param) {
        app('model_win_jackpot_next')->where('id', $param['id'])->update($param);
    }

}


?>